home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name flseek -- Position the file pointer
- *
- * Synopsis ercode = flseek(handle,mov,ppos);
- * int ercode DOS error return code
- * int handle Handle of file to be positioned
- * int mov Positioning technique
- * long *ppos File position
- *
- * Description Each handle has a file position pointer associated with it.
- * FLSEEK moves the pointer using the technique specified in
- * mov. The possibilities are:
- *
- * 0 - Absolute. Move the pointer to the offset specified
- * in pos from the beginning of the file.
- * 1 - Relative. Move the pointer to the offset from the
- * current file position.
- * 2 - End of File. Move the pointer to the offset from
- * the end of the file.
- *
- * Upon input, ppos contains the offset in bytes to move
- * the file pointer, and upon return, the new file pointer
- * location. The function FLREAD and FLWRITE also alter
- * the file pointer position.
- *
- * Returns ercode DOS 2.0 function error return code
- * ppos The file pointer position after the seek
- * has been accomplished. If an error is
- * encountered, the position is set to -1.
- *
- * Version 1.0 (C)Copyright Blaise Computing Inc. 1983
- *
- **/
- #define utbyword(a,b) (((a)<<8)|((b)&0x00ff)) /* a is high, b low */
-
- struct dreg
- {
- unsigned ax,bx,cx,dx,si,di,ds,es;
- };
- #define DOSREG struct dreg
-
- int flseek(handle,mov,ppos)
- int handle,mov;
- long *ppos;
- {
-
- DOSREG dos_reg;
- int ercode,utinit(),dos();
-
- utinit(&dos_reg); /* Initialize registers */
- dos_reg.ax = utbyword(0x42,mov); /* Function call 42 */
- dos_reg.bx = handle;
- dos_reg.cx = (unsigned)((*ppos >> 16) & 0xffff); /* High order and*/
- dos_reg.dx = (unsigned)(*ppos & 0xffff); /* low order word */
- ercode = dos(&dos_reg);
- if (ercode == 0)
- *ppos = ((long)(dos_reg.dx) << 16) + (long)dos_reg.ax;
- else
- *ppos = -1;
-
- return(ercode);
-
- }